#########################################################################
##
## This file is part of the SAMRAI distribution.  For full copyright
## information, see COPYRIGHT and LICENSE.
##
## Copyright:     (c) 1997-2019 Lawrence Livermore National Security, LLC
## Description:   Multiblock performance tests.
##
#########################################################################

SAMRAI        = @top_srcdir@
SRCDIR        = @srcdir@
SUBDIR        = source/test/performance/multiblock
VPATH         = @srcdir@
TESTTOOLS     = ../../testtools
OBJECT        = ../../../..
REPORT        = $(OBJECT)/report.xml
TESTLIBDIR    = $(OBJECT)/source/test/testlib
TESTLIB       = $(TESTLIBDIR)/libSAMRAI_test$(LIB_SUFFIX)

default:      check

include $(OBJECT)/config/Makefile.config

SUBDIRS = fortran

CPPFLAGS_EXTRA= 

NUM_TESTS     = 0

TEST_NPROCS   = @TEST_NPROCS@

CXX_OBJS      = MblkGeometry.o main.o MblkLinAdv.o \
		SkeletonOutersideDoubleWeightedAverage.o

F_OBJS      = fortran/stufprobc.o fortran/trace1d.o fortran/trace2d.o \
	      fortran/trace3d.o fortran/grad2d.o fortran/grad3d.o \
	      fortran/flux2d.o fortran/flux3d.o fortran/fluxcorner3d.o \
	      fortran/stable2d.o fortran/stable3d.o fortran/init2d.o \
	      fortran/init3d.o

main:	$(CXX_OBJS) $(F_OBJS) $(LIBSAMRAIDEPEND) $(TESTLIB)
	(cd $(TESTLIBDIR) && $(MAKE) library) || exit 1
	for DIR in $(SUBDIRS); do if test -d $$DIR; then (cd $$DIR && $(MAKE) $@) ; fi || exit 1; done
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(CXX_OBJS) $(F_OBJS) $(TESTLIB) \
	$(LIBSAMRAI) $(LDLIBS) -o $@

# Prevents "No rule to make target" error.  Built in the rule for main.
$(TESTLIB):

fortran/stufprobc.o:

fortran/trace1d.o:

fortran/trace2d.o:

fortran/trace3d.o:

fortran/grad2d.o:

fortran/grad3d.o:

fortran/flux2d.o:

fortran/flux3d.o:

fortran/fluxcorner3d.o:

fortran/stable2d.o:

fortran/stable3d.o:

fortran/init2d.o:

fortran/init3d.o:

check:

checkcompile: main

checktest:
	$(RM) makecheck.logfile
	$(MAKE) check 2>&1 | $(TEE) makecheck.logfile
	$(TESTTOOLS)/testcount.sh $(TEST_NPROCS) $(NUM_TESTS) 0 makecheck.logfile
	$(RM) makecheck.logfile

examples:

perf2d:       main
	@for i in performance_inputs/*.2d.*input ; do \
	 $(OBJECT)/config/serpa-run $(TEST_NPROCS) \
	       ./main $${i}; \
	done

perf3d:       main
	@for i in performance_inputs/*.3d.*input ; do \
	 $(OBJECT)/config/serpa-run $(TEST_NPROCS) \
	       ./main $${i}; \
	done

perf:
	$(MAKE) perf2d
	$(MAKE) perf3d

everything:
	$(MAKE) checkcompile || exit 1
	$(MAKE) checktest
	$(MAKE) examples
	$(MAKE) perf

checkclean:
	$(CLEAN_COMMON_CHECK_FILES)
	$(RM) *.timing*

clean: checkclean
	$(CLEAN_COMMON_TEST_FILES)
	$(RM) main
	for DIR in $(SUBDIRS); do if test -d $$DIR; then (cd $$DIR && $(MAKE) $@) ; fi || exit 1; done

redo:
	$(RM) main

include $(SRCDIR)/Makefile.depend


